<script lang="ts">
import {vDraggable } from 'vue-draggable-plus'
export default {
  name:"ChooseSet",
  data(){
    return {
      setList: [],
      column: 4
    }
  },
  directives:{
    draggable:vDraggable
  },
  computed:{
    templateFr(){
      return `repeat(${this.column},30px)`
    }
  },
  mounted(){
    for (let i = 0; i < 30; i++) {
      this.setList.push({id:i+1})
    }
  }
}
</script>

<template>
  <input type="number" name="" id="" :value="column" @change="(e)=>column = e.target?.value">
    <div class="choose-box" :style="{gridTemplateColumns:templateFr}"  v-draggable="[setList,{
          /* 不需要动画删除animation */
          animation: 150,
        }]">
      <template v-for="i in setList">
        <div class="set-item" >
          {{i.id}}
        </div>
      </template>
    </div>
</template>

<style scoped lang="scss">
.choose-box {
  margin-top: 10px;
  padding: 5px;
  box-sizing: border-box;
  width: 450px;
  display: grid;
  gap: 10px;
  .set-item {
    border: 1px solid black;
    text-align: center;
    // 设置宽高比
    aspect-ratio: 1
  }
}
</style>